package com.ww.java8.fp.stream;


import com.alibaba.fastjson.JSON;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class PeekDemo {

    public static void main(String[] args) {
        List<Person> personList = new ArrayList<>();
        Person p1 = new Person();
        p1.name = "张_三";
        Person p2 = new Person();
        p2.name = "李_四";
        personList.add(p1);
        personList.add(p2);

        List<Person> list = personList.stream().peek(person -> person.name = person.name.split("_")[1]).collect(Collectors.toList());

        System.out.println(JSON.toJSONString(list));
        System.out.println(JSON.toJSONString(personList));
    }
}

class Person {
    public String name;
}
